﻿using wscf.lightblue.Build;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
using System.Configuration;

namespace wscf.lightblue.Test
{
	[TestClass()]
	public class BuilderTest : ActivityBaseTest
	{
		string RootDirectory
		{
			get
			{
				string rd = ConfigurationManager.AppSettings["RootDirectory"];
				Assert.IsTrue(Directory.Exists(rd));
				return rd;
			}
		}

		/// <summary>
		/// wscf.lightblue must be installed on the machine for this test to work
		/// </summary>
		[TestMethod()]
		public void Execute()
		{
			Builder target = new Builder
			{
				Name = "Builder.ExecuteTest",
				ExcludeFolders = "bin,TestResults",
				RootDirectory = this.RootDirectory,
				Rebuild = true,
				SearchPatterns = "*.wsdl,*.xsd",
				ServiceContractsFolder = Path.Combine(Environment.CurrentDirectory, "Builder.ServiceContractsDirectory"),
				ProjectsToBuild = new List<string> 
				{ 
					@"..\..\..\wscf.lightblue.Test.Common\wscf.lightblue.Test.Common.csproj"
				},
				ServiceAssembliesFolder = Path.Combine(Environment.CurrentDirectory, "Builder.ServiceAssembliesFolder")
			};
			target.Execute();
			Assert.IsFalse(target.IsError);

			target.Rebuild = false;
			target.Execute();
			Assert.IsFalse(target.IsError);

			target.Rebuild = true;
			target.Debug = true;
			target.Execute();
			Assert.IsFalse(target.IsError);

			target.Rebuild = false;
			target.Execute();
			Assert.IsFalse(target.IsError);
		}

	}
}
